3.426 \(\int \tan ^2(c+d x) (a+b \tan (c+d x))^2 \, dx\)

Optimal. Leaf size=63 \[ -x \left (a^2-b^2\right )+\frac{(a+b \tan (c+d x))^3}{3 b d}+\frac{2 a b \log (\cos (c+d x))}{d}-\frac{b^2 \tan (c+d x)}{d} \]

[Out]

-((a^2 - b^2)*x) + (2*a*b*Log[Cos[c + d*x]])/d - (b^2*Tan[c + d*x])/d + (a + b*Tan[c + d*x])^3/(3*b*d)

________________________________________________________________________________________

Rubi [A]  time = 0.0515594, antiderivative size = 63, normalized size of antiderivative = 1., number of steps used = 3, number of rules used = 3, integrand size = 21, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.143, Rules used = {3543, 3477, 3475} \[ -x \left (a^2-b^2\right )+\frac{(a+b \tan (c+d x))^3}{3 b d}+\frac{2 a b \log (\cos (c+d x))}{d}-\frac{b^2 \tan (c+d x)}{d} \]

Antiderivative was successfully verified.

[In]

Int[Tan[c + d*x]^2*(a + b*Tan[c + d*x])^2,x]

[Out]

-((a^2 - b^2)*x) + (2*a*b*Log[Cos[c + d*x]])/d - (b^2*Tan[c + d*x])/d + (a + b*Tan[c + d*x])^3/(3*b*d)

Rule 3543

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^2, x_Symbol] :> Simp[
(d^2*(a + b*Tan[e + f*x])^(m + 1))/(b*f*(m + 1)), x] + Int[(a + b*Tan[e + f*x])^m*Simp[c^2 - d^2 + 2*c*d*Tan[e
 + f*x], x], x] /; FreeQ[{a, b, c, d, e, f, m}, x] && NeQ[b*c - a*d, 0] &&  !LeQ[m, -1] &&  !(EqQ[m, 2] && EqQ
[a, 0])

Rule 3477

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^2, x_Symbol] :> Simp[(a^2 - b^2)*x, x] + (Dist[2*a*b, Int[Tan[c + d
*x], x], x] + Simp[(b^2*Tan[c + d*x])/d, x]) /; FreeQ[{a, b, c, d}, x]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int \tan ^2(c+d x) (a+b \tan (c+d x))^2 \, dx &=\frac{(a+b \tan (c+d x))^3}{3 b d}-\int (a+b \tan (c+d x))^2 \, dx\\ &=-\left (a^2-b^2\right ) x-\frac{b^2 \tan (c+d x)}{d}+\frac{(a+b \tan (c+d x))^3}{3 b d}-(2 a b) \int \tan (c+d x) \, dx\\ &=-\left (a^2-b^2\right ) x+\frac{2 a b \log (\cos (c+d x))}{d}-\frac{b^2 \tan (c+d x)}{d}+\frac{(a+b \tan (c+d x))^3}{3 b d}\\ \end{align*}

Mathematica [A]  time = 0.302023, size = 99, normalized size = 1.57 \[ -\frac{a^2 \tan ^{-1}(\tan (c+d x))}{d}+\frac{a^2 \tan (c+d x)}{d}+\frac{a b \left (\tan ^2(c+d x)+2 \log (\cos (c+d x))\right )}{d}+\frac{b^2 \tan ^3(c+d x)}{3 d}+\frac{b^2 \tan ^{-1}(\tan (c+d x))}{d}-\frac{b^2 \tan (c+d x)}{d} \]

Antiderivative was successfully verified.

[In]

Integrate[Tan[c + d*x]^2*(a + b*Tan[c + d*x])^2,x]

[Out]

-((a^2*ArcTan[Tan[c + d*x]])/d) + (b^2*ArcTan[Tan[c + d*x]])/d + (a^2*Tan[c + d*x])/d - (b^2*Tan[c + d*x])/d +
 (b^2*Tan[c + d*x]^3)/(3*d) + (a*b*(2*Log[Cos[c + d*x]] + Tan[c + d*x]^2))/d

________________________________________________________________________________________

Maple [A]  time = 0.005, size = 106, normalized size = 1.7 \begin{align*}{\frac{ \left ( \tan \left ( dx+c \right ) \right ) ^{3}{b}^{2}}{3\,d}}+{\frac{ab \left ( \tan \left ( dx+c \right ) \right ) ^{2}}{d}}+{\frac{{a}^{2}\tan \left ( dx+c \right ) }{d}}-{\frac{{b}^{2}\tan \left ( dx+c \right ) }{d}}-{\frac{ab\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) }{d}}-{\frac{{a}^{2}\arctan \left ( \tan \left ( dx+c \right ) \right ) }{d}}+{\frac{\arctan \left ( \tan \left ( dx+c \right ) \right ){b}^{2}}{d}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(tan(d*x+c)^2*(a+b*tan(d*x+c))^2,x)

[Out]

1/3/d*tan(d*x+c)^3*b^2+a*b*tan(d*x+c)^2/d+a^2*tan(d*x+c)/d-b^2*tan(d*x+c)/d-1/d*a*b*ln(1+tan(d*x+c)^2)-1/d*a^2
*arctan(tan(d*x+c))+1/d*arctan(tan(d*x+c))*b^2

________________________________________________________________________________________

Maxima [A]  time = 1.59171, size = 105, normalized size = 1.67 \begin{align*} \frac{b^{2} \tan \left (d x + c\right )^{3} + 3 \, a b \tan \left (d x + c\right )^{2} - 3 \, a b \log \left (\tan \left (d x + c\right )^{2} + 1\right ) - 3 \,{\left (a^{2} - b^{2}\right )}{\left (d x + c\right )} + 3 \,{\left (a^{2} - b^{2}\right )} \tan \left (d x + c\right )}{3 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2*(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

1/3*(b^2*tan(d*x + c)^3 + 3*a*b*tan(d*x + c)^2 - 3*a*b*log(tan(d*x + c)^2 + 1) - 3*(a^2 - b^2)*(d*x + c) + 3*(
a^2 - b^2)*tan(d*x + c))/d

________________________________________________________________________________________

Fricas [A]  time = 1.77385, size = 184, normalized size = 2.92 \begin{align*} \frac{b^{2} \tan \left (d x + c\right )^{3} + 3 \, a b \tan \left (d x + c\right )^{2} - 3 \,{\left (a^{2} - b^{2}\right )} d x + 3 \, a b \log \left (\frac{1}{\tan \left (d x + c\right )^{2} + 1}\right ) + 3 \,{\left (a^{2} - b^{2}\right )} \tan \left (d x + c\right )}{3 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2*(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

1/3*(b^2*tan(d*x + c)^3 + 3*a*b*tan(d*x + c)^2 - 3*(a^2 - b^2)*d*x + 3*a*b*log(1/(tan(d*x + c)^2 + 1)) + 3*(a^
2 - b^2)*tan(d*x + c))/d

________________________________________________________________________________________

Sympy [A]  time = 0.417101, size = 94, normalized size = 1.49 \begin{align*} \begin{cases} - a^{2} x + \frac{a^{2} \tan{\left (c + d x \right )}}{d} - \frac{a b \log{\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{d} + \frac{a b \tan ^{2}{\left (c + d x \right )}}{d} + b^{2} x + \frac{b^{2} \tan ^{3}{\left (c + d x \right )}}{3 d} - \frac{b^{2} \tan{\left (c + d x \right )}}{d} & \text{for}\: d \neq 0 \\x \left (a + b \tan{\left (c \right )}\right )^{2} \tan ^{2}{\left (c \right )} & \text{otherwise} \end{cases} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)**2*(a+b*tan(d*x+c))**2,x)

[Out]

Piecewise((-a**2*x + a**2*tan(c + d*x)/d - a*b*log(tan(c + d*x)**2 + 1)/d + a*b*tan(c + d*x)**2/d + b**2*x + b
**2*tan(c + d*x)**3/(3*d) - b**2*tan(c + d*x)/d, Ne(d, 0)), (x*(a + b*tan(c))**2*tan(c)**2, True))

________________________________________________________________________________________

Giac [B]  time = 2.17229, size = 911, normalized size = 14.46 \begin{align*} \text{result too large to display} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(tan(d*x+c)^2*(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

-1/3*(3*a^2*d*x*tan(d*x)^3*tan(c)^3 - 3*b^2*d*x*tan(d*x)^3*tan(c)^3 - 3*a*b*log(4*(tan(c)^2 + 1)/(tan(d*x)^4*t
an(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)^3*tan(c)^3
 - 9*a^2*d*x*tan(d*x)^2*tan(c)^2 + 9*b^2*d*x*tan(d*x)^2*tan(c)^2 - 3*a*b*tan(d*x)^3*tan(c)^3 + 9*a*b*log(4*(ta
n(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c)
+ 1))*tan(d*x)^2*tan(c)^2 + 3*a^2*tan(d*x)^3*tan(c)^2 - 3*b^2*tan(d*x)^3*tan(c)^2 + 3*a^2*tan(d*x)^2*tan(c)^3
- 3*b^2*tan(d*x)^2*tan(c)^3 + 9*a^2*d*x*tan(d*x)*tan(c) - 9*b^2*d*x*tan(d*x)*tan(c) - 3*a*b*tan(d*x)^3*tan(c)
+ 3*a*b*tan(d*x)^2*tan(c)^2 - 3*a*b*tan(d*x)*tan(c)^3 + b^2*tan(d*x)^3 - 9*a*b*log(4*(tan(c)^2 + 1)/(tan(d*x)^
4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c) + 1))*tan(d*x)*tan(c)
- 6*a^2*tan(d*x)^2*tan(c) + 9*b^2*tan(d*x)^2*tan(c) - 6*a^2*tan(d*x)*tan(c)^2 + 9*b^2*tan(d*x)*tan(c)^2 + b^2*
tan(c)^3 - 3*a^2*d*x + 3*b^2*d*x + 3*a*b*tan(d*x)^2 - 3*a*b*tan(d*x)*tan(c) + 3*a*b*tan(c)^2 + 3*a*b*log(4*(ta
n(c)^2 + 1)/(tan(d*x)^4*tan(c)^2 - 2*tan(d*x)^3*tan(c) + tan(d*x)^2*tan(c)^2 + tan(d*x)^2 - 2*tan(d*x)*tan(c)
+ 1)) + 3*a^2*tan(d*x) - 3*b^2*tan(d*x) + 3*a^2*tan(c) - 3*b^2*tan(c) + 3*a*b)/(d*tan(d*x)^3*tan(c)^3 - 3*d*ta
n(d*x)^2*tan(c)^2 + 3*d*tan(d*x)*tan(c) - d)